Socket
Socket
Sign inDemoInstall

postcss-discard

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-discard

PostCSS plugin to discard rules, atrules or declarations by selector, RegExp or callback function


Version published
Weekly downloads
24K
increased by4.6%
Maintainers
1
Weekly downloads
 
Created
Source

PostCSS Discard Build Status

PostCSS plugin to discard rules by selector, RegExp, or @type. Also usable to generate a diff from two stylesheets

Usage

const discard = require('postcss-discard');
postcss([discard(options)]);

See PostCSS docs for examples for your environment.

Options
NameTypeDescription
atruleString, RegExp, FunctionMatch atrule like @font-face
ruleString, RegExp, FunctionMatch rule like .big-background-image {...}
declString, RegExp, FunctionMatch declarations
cssStringCSS String or path to file containing css

You can also pass a filter function for any of the supported types. The function is invoked with two arguments (node, value).

  • node The currently processed AST node generated by postcss.
  • value Current value.

Return true if the element should be discarded.

Examples

Diffing stylesheets

postcss(discard({css: 'STYLES TO BE REMOVED'})).process('ORIGINAL CSS').css;

Discard by specifying rules

.bg {
  width: 100%;
  height: 100%;
  background-image: url('some/big/image.png');
}

@font-face {
  font-family: 'My awesome font';
}

@media print {
  ...;
}
postcss([
  discard({
    atrule: ['@font-face', /print/],
  }),
]);
.bg {
  width: 100%;
  height: 100%;
}

Keywords

FAQs

Package last updated on 29 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc